package com.spring.sunflower.conversation;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.tencent.imsdk.v2.V2TIMMessage;

import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * Created by Kevin on 2021/6/8<br/>
 * <p>
 * Describe:<br/>
 */
public class ConversationAdapterX extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context context;
    private List<V2TIMMessage> data;
    private static final int MSG_TYPE_HEADER=0;
    /**
     * 文本类型消息
     */
    public static final int MSG_TYPE_TEXT = 1;
    /**
     * 图片类型消息
     */
    public static final int MSG_TYPE_IMAGE = 3;
    /**
     * 语音类型消息
     */
    public static final int MSG_TYPE_AUDIO = 4;
    /**
     * 视频类型消息
     */
    public static final int MSG_TYPE_VIDEO = 5;
    /**
     * 文件类型消息
     */
    public static final int MSG_TYPE_FILE = 6;
    /**
     * 位置类型消息
     */
    public static final int MSG_TYPE_LOCATION = 7;

    /**
     * 自定义图片类型消息
     */
    public static final int MSG_TYPE_CUSTOM_FACE = 8;
    /**
     * 自定义消息
     */
    public static final int MSG_TYPE_CUSTOM = 2;

    /**
     * 提示类信息
     */
    public static final int MSG_TYPE_TIPS = 0x100;
    /**
     * 群创建提示消息
     */
    public static final int MSG_TYPE_GROUP_CREATE = 0x101;
    /**
     * 群解散提示消息
     */
    public static final int MSG_TYPE_GROUP_DELETE = 0x102;
    /**
     * 群成员加入提示消息
     */
    public static final int MSG_TYPE_GROUP_JOIN = 0x103;
    /**
     * 群成员退群提示消息
     */
    public static final int MSG_TYPE_GROUP_QUITE = 0x104;
    /**
     * 群成员被踢出群提示消息
     */
    public static final int MSG_TYPE_GROUP_KICK = 0x105;
    /**
     * 群名称修改提示消息
     */
    public static final int MSG_TYPE_GROUP_MODIFY_NAME = 0x106;
    /**
     * 群通知更新提示消息
     */
    public static final int MSG_TYPE_GROUP_MODIFY_NOTICE = 0x107;
    /**
     * 群音视频呼叫提示消息
     */
    public static final int MSG_TYPE_GROUP_AV_CALL_NOTICE = 0x108;

    /**
     * 消息未读状态
     */
    public static final int MSG_STATUS_READ = 0x111;
    /**
     * 消息删除状态
     */
    public static final int MSG_STATUS_DELETE = 0x112;
    /**
     * 消息撤回状态
     */
    public static final int MSG_STATUS_REVOKE = 0x113;
    public ConversationAdapterX(Context context, List<V2TIMMessage> data) {
        this.context = context;
        this.data = data;
    }

    public void addData(List<V2TIMMessage> d) {
        data.addAll(d);
        notifyDataSetChanged();
    }

    public void updateData(List<V2TIMMessage> d) {
        this.data.clear();
        data.addAll(data);
        notifyDataSetChanged();
    }

    public void addItem(int position,V2TIMMessage d) {
        data.add(d);
        notifyItemChanged(position);
    }

    public void deleteItem(int position) {
        data.remove(position);
        notifyItemRemoved(position);
    }
    @NonNull
    @NotNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {

        return null;
    }

    @Override
    public void onBindViewHolder(@NonNull @NotNull RecyclerView.ViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    @Override
    public int getItemViewType(int position) {
//        if (position == 0) {
//            return MSG_TYPE_HEADER;
//        }
        V2TIMMessage v2TIMMessage = data.get(position);
        return v2TIMMessage.getElemType();
    }

//    public static RecyclerView.ViewHolder crateVH(ViewGroup parent,RecyclerView.Adapter adapter, int viewType){
//        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
//        RecyclerView.ViewHolder holder = null;
//        View view = null;
//        view = inflater.inflate(R.layout.adapter_conversation_activity, parent, false);
//        switch (viewType) {
//            case V2TIMMessage.V2TIM_ELEM_TYPE_TEXT:
//                break;
//        }
//    }
}
